package com.dg11185.nearshop.net.response;

import java.io.Serializable;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * 登录结果
 * 
 * @author wanliang527
 * @date 2014-4-29
 */
public class LoginResponse implements Serializable{
    /**
     * 
     */
    private static final long serialVersionUID = -2886797203471532428L;
    public final static String SUCCESS = "SUCCESS";// 注册成功
    public final static String FAILE = "FAILE";// 调用失败
    public final static String ILLEGAL_PAR = "ILLEGAL_PAR";// 参数异常
    public final static String MEM_NOTFOUND = "MEM_NOTFOUND";// 会员不存在
    public final static String MEM_ILLEGALPWD = "MEM_ILLEGALPWD";// 密码不正确
    public final static String EXCEPTION = "EXCEPTION";// WS调用失败
    public final static String ILLEGAL_SIGN = "ILLEGAL_SIGN";// 签名无效

    public String responseStr = "";
    public String status = "";
    public String userId = ""; // 用户ID
    public String userName = "";// 用户名
    public String mobilePhone = "";// 手机号
    public String email = "";// 邮箱
    public String signature = "";// 签名
    public String minPhoto = "";// 头像地址

    public void parseJson(String response) throws JSONException {
        this.responseStr = response;
        JSONObject jsonObject = new JSONObject(response);
        status = jsonObject.getString("status");

        if (!jsonObject.isNull("member")) {
            JSONObject member = jsonObject.getJSONObject("member");
            userId = member.optString("userId");
            userName = member.getString("userName");
            mobilePhone = member.optString("mobilePhone");
            email = member.optString("email");
            signature = member.optString("signature");
            minPhoto = member.optString("minPhoto");
        }

    }
}
